package main

import "fmt"

// 结构体方法
// 1.结构体可以没有字段 struct without fields
func main() {
	test01()
}

func test01() {

	var m1 MethodUtils = MethodUtils{}
	m1.print01()
	m1.print02(2, 6)
	res := m1.print03(2, 6)
	fmt.Println("面积=", res)
	(&m1).print04(8)

}

type MethodUtils struct {
}

func (m MethodUtils) print01() {
	for i := 1; i <= 10; i++ {
		for j := 1; j <= 8; j++ {
			fmt.Print("*")
		}
		fmt.Println()
	}
}

func (method MethodUtils) print02(m int, n int) {
	for i := 1; i <= m; i++ {
		for j := 1; j <= n; j++ {
			fmt.Print("*")
		}
		fmt.Println()
	}
}

func (method MethodUtils) print03(m float64, n float64) float64 {
	return m * n
}

func (method *MethodUtils) print04(n int) {
	if n%2 == 0 {
		fmt.Println("偶数")
	} else {
		fmt.Println("奇数")
	}

}
